﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;

namespace OneCaps.DB
{
    // Infrastructure/Data/SqlSugar/SqlSugarDbContext.cs
    public static class SqlSugarDbContext
    {
        public static ISqlSugarClient Create(string connectionString, DbType dbType)
        {
            return new SqlSugarClient(new ConnectionConfig
            {
                ConnectionString = connectionString,
                DbType = dbType,
                IsAutoCloseConnection = true,
                InitKeyType = InitKeyType.Attribute
            });
        }
    }

    // Startup.cs
    //    services.AddScoped<ISqlSugarClient>(provider => 
    //    SqlSugarDbContext.Create(Configuration.GetConnectionString("Default"), DbType.SqlServer));

    //services.AddScoped(typeof(IRepository<,>), typeof(SqlSugarRepository<,>));
}
